Ext.ns("org.cancerregulome.redi");

org.cancerregulome.redi.Viewport = Ext.extend(Object, {

    constructor: function(centerPanel, config) {
        Ext.apply(this, config);

        org.cancerregulome.redi.Viewport.superclass.constructor.call(this);

        centerPanel.region = "center";

        this.viewport = new Ext.Viewport({
            frame: true,
            border: true,
            layout:'border',
            defaults: {
                margins: "5 5 5 5",
                padding: "5 5 5 5",
                frame: true,
                border: true,
                height: 200,
                width: 300
            },
            items: [
                this.getBanner(),
                centerPanel,
                this.getFooter()
            ]
        });
    },

    getBanner: function() {
        return {
            region: "north",
            margins: "0 0 0 0",
            height: 110,
            frame: false,
            border: false,
            html: '<img src="images/banner.png" alt="REdi"/>',
            tbar: this.menuBar
        };
    },

    getFooter: function() {
        var links = [];
        var addLink = function(link, title) {
            var linkStr = '<div><a href="' + link + '" target="_blank">' + title + '</a></div>';
            links.push(Ext.DomHelper.append(Ext.getBody(), linkStr, true).dom);
        };
        addLink("http://cancerregulome.org", "Cancer Regulome Project");
        addLink("http://cancergenome.nih.gov", "TCGA");
        addLink("http://systemsbiology.org", "Institute for Systems Biology");
        addLink("http://systemsbiology.org/shmulevich-group", "Shmulevich Lab");
        addLink("http://codefor.systemsbiology.net", "Code for Systems Biology");

        return {
            region: "south",
            layout: "hbox",
            height: 33,
            border: false,
            frame: true,
            padding: "1 1 1 1",
            margins: "1 1 1 1",
            layoutConfig: { pack: "center", align: "middle", defaultMargins: "0 10 0 0" },
            items: links
        };
    }
});
